from django.contrib import admin
from .models import VideoTask


@admin.register(VideoTask)
class VideoTaskAdmin(admin.ModelAdmin):
    list_display = ['volc_task_id', 'user', 'status', 'prompt', 'resolution', 'aspect_ratio', 'duration', 'price', 'create_time']  # 添加price字段
    list_filter = ['status', 'resolution', 'aspect_ratio', 'duration', 'create_time', 'is_deleted']
    search_fields = ['volc_task_id', 'prompt', 'user__username']
    readonly_fields = ['volc_task_id', 'price', 'create_time']  # price设置为只读，由系统自动计算
    
    def get_queryset(self, request):
        # 默认不显示软删除的记录
        return super().get_queryset(request).filter(is_deleted=False)
